package com.modular.iot.action;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Opt;
import cn.hutool.json.JSONUtil;
import com.ToolOpt;
import com.modular.iot.bo.IotDataQueryInBo;
import ntd.action.ActionAbs;
import ntd.action.bo.ActionInfo;
import ntd.action.bo.ActionOutBo;
import ntd.util.frame.javacv.tool.ToolAiUserSites;

public class ActionIotData extends ActionAbs {

    @Override
    public ActionInfo info() {
        return new ActionInfo("IOT-数据查询", "action-iot-data", new ActionIotData());
    }

    @Override
    public ActionOutBo handle() {
        IotDataQueryInBo iotDataQueryInBo = actionInBo.t(IotDataQueryInBo.class);

        if (CollUtil.isEmpty(iotDataQueryInBo.getDeviceCodes())) {
            Opt.ofEmptyAble(ToolAiUserSites.getCurrMns()).ifPresent(iotDataQueryInBo::setDeviceCodes);
        }

        return new ActionOutBo(ToolOpt.OPT_T_DATA.queryIotData(iotDataQueryInBo));
    }
}
